﻿using System.Collections.Generic;
using System.Text;
using System.Web;

public static class BreadcrumbsBuilder
{
  public static string SitePath()
  {
    StringBuilder sb = new StringBuilder();
    SiteMapNode currentNode = SiteMap.CurrentNode;
    sb.Append("<ul class=\"breadcrumb\">");
    if (currentNode != null) {
      var node = currentNode;
      var nodes = new Stack<SiteMapNode>();
      while (node.ParentNode != null) {
        nodes.Push(node.ParentNode);
        node = node.ParentNode;
      }
      while (nodes.Count != 0) {
        SiteMapNode n = nodes.Pop();
        sb.Append("<li><a href=\""+n.Url+"\">"+n.Title+"</a><span class=\"divider\">/</span></li>");
      }
      sb.Append("<li class=\"active\">"+currentNode.Title+"</li>");
    }
    sb.Append("</ul>");
    return sb.ToString();
  }
}